home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
pascal
/
xlib.zip
/
XSTREAM.DOC
< prev
next >
Wrap
Text File
|
1992-09-06
|
11KB
|
340 lines
XStream
-------
This unit give some more stream-objects than the ones you
know from turbo-vision. If you need more informations
about stream you should have a look on the STREAM13.ZIP stream
collection from DJ Murdoch.
▌TObject▐─┬...
│
├─▌TStream─────┬─▌TDosStream▐────────▌TBufStream▐
. ├─▌TEmsStream▐
. ├──TXmsStream
. ├──TMemStream
├──TObjStream
├──TPortStream──────┬──TLptStream
│ └──TComStream
└──TNulStream──────────TCrcStream
!! Note ▌Txxxxxx▐ are object came from Turbo-Vision
TMemStream
~~~~~~~~~~
This stream can be used for temporairly objects where you don't
want to open an extra file. Note than this stream use the HEAP
for the data, so don't use it extensive. For bigger memory-
streams use TEmsStream or TXmsStream, instead of this one.
I myself use this stream for copy objects, patched load-constructors,
etc.
Fields:
-------
BuffSize : WORD The size of the buffer which were allocated
Buffer : POINTER A Pointer to access the buffer on the heap
Position : LONGINT Position within the datablock
Methods
-------
CONSTRUCTOR Init( ASize : Word );
Try to allocate the specified size on heap. If not successfull
the error-method would be called but no fail.
DESTRUCTOR Done; virtual;
Deallocate the memory on the heap
FUNCTION GetPos: LongInt; virtual;
Only return the Position field
FUNCTION GetSize: LongInt; virtual;
Only return the BuffSize field
PROCEDURE Read(var Buf; Count: word); virtual;
Transfer some data from the heap to the buffer
PROCEDURE Seek(Pos: LongInt); virtual;
Move the Position to a new value
PROCEDURE Write(var Buf; Count: word); virtual;
Transder some data from the buffer to the heap
TObjStream
~~~~~~~~~~
This stream is a descendant from TMemStream, with the difference that
it not allocate the data from heap, but set it to some existing data
in the EXE-Code. So you can link data with the BINOBJ to your EXE and
then read it by this stream. I use this for programs that should be
run on floppy disks that can be changed during run-time. A normal
*.RES file must be aviable all the time, a *.RES linked to the program
with BINOBJ must only be aviable on program-loading !
Here's a short example for linking a resource to a program.
procedure Resource; external; { from the obj file }
.....
New( PObjStream, Init( @Resource ));
Methods
-------
CONSTRUCTOR Init( AAddr:Pointer );
Set the Buffer to the AAddr address and the BuffSize to
65000. I use such a big value because there is no way to
determine the size of a linked OBJ file ! So it's possible
to read-after the end of the stream without any errors.
For Resources this isn't so bad, because they control it
by their own.
DESTRUCTOR Done; virtual;
Only call the TStream.Done, don't deallocate the buffer.
PROCEDURE Write(var Buf; Count: word); virtual;
Do nothing because it shouldn't be possible to write to
the code segment.
TPortStream
~~~~~~~~~~~
This stream is an abstract one that never be used directly from
a program. It's a stream that can handle any output port and would
be used in his descendants TComStream and TLptStream. It can handle
various port-numbers and a timeout setting.
Fields:
-------
ThePort : Integer Number which port is used
TimeOut : Byte Value for TimeOut control. Mostly in seconds
OldTimeOut : Byte Old-TimeOut Value for the port, use for reset
it at Done
Methods:
--------
constructor Init( APort:Integer; ATimeOut:Byte);
Set the parameters to the fields "ThePort" and "TimeOut"
destructor Done; virtual;
Calls SetTimeOut with the OldTimeOut value
constructor Load( var S:TStream );
Load the object from a stream
procedure Store( var S:TStream );
Store the object to a stream
function GetTimeOut:Byte; virtual;
Abstract method for get the TimeOut value for this port
procedure SetTimeOut(B:Byte); virtual;
Abstract method to set the TimeOut for this port
function InitPort:Boolean; virtual;
Initalize the port. If successfully True should be returned
TLptStream
~~~~~~~~~~
A stream for writing to the parallel ports LPT1..LPTn on the computer.
Is a descendant from the TPortStream.
These errors can be reported to the error-method:
ErrorInfo and $01 --> Time out
" and $08 --> I/O Error
" and $20 --> Out of paper
Constants:
---------
Lpt1 = 1;
Lpt2 = 2;
Lpt3 = 3;
Lpt4 = 4;
Methods:
-------
constructor Init( APort:Integer; ATimeOut:Byte);
Call InitPort and set the TimeOut to the new value
constructor Load( var S:TStream );
Loads this object from a screen. Overwrite was neccessary to
initalize the port after Loading.
function GetTimeOut:Byte; virtual;
Return the timeout value for the port. The BIOS Aera
at $40:$78 would be used for this.
procedure SetTimeOut(B:Byte); virtual;
Set a TimeOut for the printer-port. BIOS Aera in segment $40
was used for this purpose.
procedure Write( var Buf; Count:Word ); virtual;
Write data to the printer. If errors occurred they were reported
to the error-method.
function InitPort:Boolean; virtual;
Initalize the port over the $17 Interrupt for printers.
TComStream
~~~~~~~~~~
A stream for writing to the serial ports COM1..COMn on the computer.
Is a descendant from the TPortStream. At this time only used it
over the interrupt $14, so that's not possible to access the
COM3..COM8 ports. I hope that's not so often used yet.
These errors can be reported to the error-method :
Errorinfo and $02 --> Overrun error
" and $04 --> Parity error
" and $08 --> framing error
" and $10 --> break detected
" and $80 --> timeout
Constants:
----------
Com1 = 1;
Com2 = 2;
Fields:
-------
ComParam : Byte; Packed information for the port, like
baud,stop-bits,parity, etc.
Methods:
-------
constructor Init( APort:Integer; ATimeOut:Byte;
ABaud:Word; AData:Byte; AParity:Char; AStop:Byte);
Call InitPort and set the TimeOut and port parameter. Baud-rates
greater than 9600 not supported over the Bios at this time !
constructor Load( var S:TStream );
Loads this object from a screen. Overwrite was neccessary to
initalize the port after loading.
procedure Store( var S:TStream );
Store the values to a stream.
function GetTimeOut:Byte; virtual;
Return the timeout value for the port. The BIOS Aera
at $40:$7C would be used for this.
procedure SetTimeOut(B:Byte); virtual;
Set a TimeOut for the serial-port. BIOS Aera in segment $40
was used for this purpose.
procedure Write( var Buf; Count:Word ); virtual;
Write data to the serial-port. If errors occurred they were reported
to the error-method.
function InitPort:Boolean; virtual;
Initalize the port over the $14 Interrupt for printers.
TNulStream
~~~~~~~~~~
This streams will eat all data that write to it, but count the
number of bytes transferd. It can be used to determine the
size of objects if you write to it. For example you write
the object to this stream before allocating the size for
TMemStream.
Fields:
-------
Size : Longint Number of bytes transferd to the write method
Methods:
-------
constructor Init;
Set "Size" to 0
function GetSize: LongInt; VIRTUAL;
Return the current value of size
function GetPos: LongInt; VIRTUAL;
Return ever zero
constructor Load( var S:TStream );
Set "Size" to 0
procedure Store( var S:TStream );
Do nothing
procedure Write( var Buf; Count:Word ); virtual;
Increase the "Size" field by "Count"
TCRCStream
~~~~~~~~~~
This stream is a descendant of TNulStream that also calculate a
easy CRC-Sum. Can be used on sending objects over channels on
that error can be occured.
Field:
------
CRC : Word The CheckSum
Methods:
--------
constructor Init;
Sets CRC to 0 and call TNulStream.Init
function GetCRC:Longint
Return the CheckSum in CRC
procedure Write(VAR Buf; Count: Word); virtual;
Simply adds the bytes of the buffer to the CRC value
TXmsStream
~~~~~~~~~~
This stream gives you access to the extended-memory in your
computer deliverd by HIMEM.SYS driver. It's simiar to the
TEmsStream for the expanded-memory came from Borland.
Field:
------
Handle : WORD; A handle for the XMS-Manager
Size : LONGINT; Size of the current stream
Position : LONGINT; Position within the stream
Blocks : WORD; Number of blocks for this stream.
XMS blocksize is 1K !
Methods:
--------
constructor Init;
Setup a handle for the xms. Also look if XMS memory exists in
your computer.
DESTRUCTOR Done; virtual;
Release the handle for the XMS-stream
FUNCTION GetPos: LongInt; virtual;
Return the current location within the stream
FUNCTION GetSize: LongInt; virtual;
Return the size of the allocated xms-memory
PROCEDURE Read(var Buf; Count: word); virtual;
Reads some data from the xms-stream
PROCEDURE Seek(Pos: LongInt); virtual;
Move the position to another location
PROCEDURE Write(var Buf; Count: word); virtual;
Write some data to the xms-stream
Other Stuff
~~~~~~~~~~~
Constants
--------
RLptStream: TStreamRec (20100) Registration constant for TLptStream
RComStream: TStreamRec (20101) Registration constant for TComStream
RNulStream: TStreamRec (20102) Registration constant for TNulStream
ResObjAddr : Pointer = Nil; This pointer you can let show to your
own resource linked as OBJ to your
program. Would be used by XRES that
if <> nil used this pointer for
the resource-file !
Procedures
----------
Procedure RegisterXStream
Register this unit